package stalker.room.roomusers;

import java.util.List;

import message.types.none.NewDataNotification;
import stalker.Stalker;
import stalker.room.RoomAction;

/**
 * Mutable class that stores information about stalkers in a room
 */

public abstract class RoomUsers {
  
  /**
   * Mutate this by registering a stalker to the room associated with this.
   * @requires stalker not null
   * @param stalker A stalker that will be registered to this set
   */
  public abstract void addUser(Stalker stalker);
  
  public abstract void removeUser(Stalker stalker);
  
  public abstract List<Stalker> getMembers();
  
  /**
   * Notifies all listeners that a stalker has been updated
   */
  public void broadCast(Stalker room) {
    assert room != null;
    List<Stalker> stalkers = getMembers();
    for (Stalker stalker : stalkers) {
      room.acceptMessage(new NewDataNotification(room, stalker));
    }
  }
  
  /**
   * Checks if the selected stalker has the required previlidge to do an action
   * @requires both parameters not null
   * @param stalker   The stalker that requests the action
   * @param action An action that user requests to do
   * @return true iff stalker is registered in this set
   */
  public abstract boolean isAuthorized(Stalker stalker, RoomAction action);
  
}
